package com.tepth.remote.control.base.listener;

import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.tepth.remote.control.base.event.LocationEvent;

import org.greenrobot.eventbus.EventBus;

/**
 * Description:
 *
 * @author Hequn.Lee
 * @date 2018/11/10
 */
public class ControlLocationListener extends BDAbstractLocationListener {

    private static final double ERROR = 4.9E-324;

    @Override
    public void onReceiveLocation(BDLocation bdLocation) {
        if (bdLocation == null) {
            return;
        }
        // 如果网络定位失败，则坐标为4.9E-324,舍去
        if (bdLocation.getLatitude() == ERROR || bdLocation.getLongitude() == ERROR) {
            return;
        }
        EventBus.getDefault().post(LocationEvent.getInstance().setBDLocation(bdLocation));
    }
}
